<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<%String contextRoot = request.getContextPath();%>
<f:loadBundle basename="properties.messages" var="msg"/>
<f:view>
<!doctype html>
<html>
    <head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <title>SISDEP - Administraci<h:outputText value="#{msg.tilde_o}" />n de Grupos de Usuarios</title>
		<meta name="description" content="" />
		<meta name="author" content="" />		     
		<link rel="stylesheet" href="<%=contextRoot%>/css/validationEngine.jquery.css" type="text/css">
		<link rel="stylesheet" href="<%=contextRoot%>/css/template.css" type="text/css">
		<link rel="stylesheet" href="<%=contextRoot%>/css/normalize.css">
		<link rel="stylesheet" href="<%=contextRoot%>/css/uniform.css"> <!-- estilos formularios -->
		<link rel="stylesheet" href="<%=contextRoot%>/css/cuerpo.css">	
		<link rel="stylesheet" href="<%=contextRoot%>/css/richCustom.css">
</head>
    <body>    
		<div id="marco"> <!--inicio contenedor --> 
		<div class="arriba-cuerpo"></div> 
		<div class="cuerpo">
		<a href="<%=contextRoot%>/index.jsf"><img src="<%= contextRoot %>/images/logos.png" /></a>
		<div class="clear"></div>
		<!-- Menu y Usuario init() -->
			<%@ include file="include/menuUsuario.jsp" %>
		<!-- Menu y Usuario end() -->
		<div class="clear"></div>
		<!-- Formulario --> 
		<div id="buscador">		
		  <h2>Administraci<h:outputText value="#{msg.tilde_o}" />n de Grupos de Usuarios</h2>		
				<h:form id="userManagerForm">
				    <span class="left">
				    <label>C<h:outputText value="#{msg.tilde_e}" />dula del Usuario<span class="asterisco">*</span></label>
					<h:inputText id="typeKey" size="20" maxlength="20" styleClass="validate[required,maxSize[20]]" 
							value="#{userPermissionManager.userId}" />&nbsp;&nbsp;&nbsp;&nbsp;									
							<h:commandButton id="userManagerButton" styleClass="botonsmall"
                                     type="submit" 
                                     value="Validar" 
                                     ondblclick="return false;" 
                                     action="#{userPermissionManager.validarUsuarioSAP}" >
                                     <a4j:support event="oncomplete" ajaxSingle="true" reRender="userInfoPanel"/>
                            </h:commandButton>
                    </span>
                    <div class="clear"></div>
					(<span class="asterisco"> * </span>) : Campo Obligatorio.
			</h:form>
		 </div>
		<div class="clear">	
               <rich:messages id="messagesPanel" layout="list" errorClass="error" fatalClass="fatal"
                    infoClass="info" warnClass="warn" styleClass="tablapaginacion">
                    <f:facet name="fatalMarker">
                        <h:graphicImage value="/images/error_icon.png" />
                    </f:facet>
                    <f:facet name="errorMarker">
                         <h:graphicImage value="/images/error_icon.png" />
                    </f:facet>
                    <f:facet name="infoMarker">
                         <h:graphicImage value="/images/success_icon.png" />
                    </f:facet>
                    <f:facet name="warnMarker">
                         <h:graphicImage value="/images/alert_icon.png" />
                    </f:facet>
            </rich:messages>
            <h:panelGrid columns="2" style="text-align:left;" frame="box" id="userInfoPanel"
                         styleClass="tablapaginacion" rendered="#{userPermissionManager.doConsultUserSAP}"
                         title="Datos del usuario" cellpadding="2" bgcolor="99cc99" >
                         
                <h:outputLabel value="Datos del Usuario:" styleClass="left" />
                <h:outputText value=""/>
                
                <h:outputLabel value="Identificaci#{msg.tilde_o}n" styleClass="left"/>
                <h:outputText value="#{userPermissionManager.userIdValidate}" styleClass="left" />

                <h:outputLabel value="Nombre Completo" styleClass="left"/>
                <h:outputText value="#{userPermissionManager.userName}" styleClass="left" />

                <h:outputLabel value="Direcci#{msg.tilde_o}n" styleClass="left"/>
                <h:outputText value="#{userPermissionManager.userAddress}" styleClass="left" />

                <h:outputText value="Tel#{msg.tilde_e}fono" styleClass="left"/>
                <h:outputLabel value="#{userPermissionManager.userTelephone}" styleClass="left" />

                <h:outputText value="Correo Electr#{msg.tilde_o}nico" styleClass="left"/>
                <h:outputLabel value="#{userPermissionManager.userEmail}" styleClass="left" />
            </h:panelGrid>
  		</div>
		<div class="clear"></div>
		<div id="buscador">		
		<h:form id="userManagerResultsForm">		
             <div class="clear"></div>
             <span class="left"><h2>Grupos de Usuarios Registrados en el Portal SAP</h2></span>
             <div class="clear"></div>             
	            <rich:dataTable id="groupTable" value="#{userPermissionManager.userGroupsManagerList}"
	                            styleClass="scrollerTable" headerClass="standardTable_Header"
	                            border="0" cellpadding="3" cellspacing="1"
	                            var="groups" rows="10" rowKeyVar="index"	                            
				                footerClass="standardTable_Header"  rowClasses="tablamultiregistrotr1,tablamultiregistrotr2"
				                onRowMouseOver="this.style.backgroundColor='#C0C0C0'"
							    onRowMouseOut="this.style.backgroundColor='#FFFFFF'" >

	                <rich:column style="text-align:center;">
	                    <f:facet name="header">
	                        <h:outputText value="Nombre del Grupo"/>
	                    </f:facet>
	                    <h:outputText value="#{groups.groupEspecification}"/>
	                </rich:column>
	
	                <rich:column style="text-align:left;">
	                    <f:facet name="header">
	                        <h:outputText value="Descripci#{msg.tilde_o}n" />                     
	                    </f:facet>
	                    <h:outputText value="#{groups.groupDescription}"/>
	                </rich:column>

	                <rich:column style="text-align:center;">
	                    <f:facet name="header">
	                        <h:outputText value="Operaci#{msg.tilde_o}n Usuario" />
	                    </f:facet>	                    
	                    <a4j:commandLink id="grantUserLink"  rendered="#{!groups.groupEnabled}"
	                                   title="Clic para Vincular el usuario al grupo seleccionado..." reRender="groupTable,messagesPanel"
	                                   action="#{userPermissionManager.grantGroup}" >
	                        <f:param name="index" value="#{index}" />
	                        <h:graphicImage style="border: 0" url="/images/error_icon.png" />							                        
	                    </a4j:commandLink>
	                    <a4j:commandLink id="excludeUserLink" rendered="#{groups.groupEnabled}"
	                                   title="Clic para Excluir el usuario del grupo seleccionado..." reRender="groupTable,messagesPanel"
	                                   action="#{userPermissionManager.excludeGroup}" >
	                        <f:param name="index" value="#{index}" />
	                        <h:graphicImage style="border: 0" url="/images/success_icon.png" />
	                    </a4j:commandLink>
	                </rich:column>
	            </rich:dataTable>
		        <h:panelGrid columns="1" styleClass="tablapaginacion"
                             columnClasses="standardTable_ColumnCentered" >
		            <rich:datascroller id="userManagerScroll"
		                    for="groupTable"
		                    fastStep="10"
		                    pageIndexVar="pageIndex"
		                    styleClass="scroller"
		                    maxPages="9" >
		                <f:facet name="first" >
		                    <h:graphicImage url="/images/arrow-first.gif" />
		                </f:facet>
		                <f:facet name="last">
		                    <h:graphicImage url="/images/arrow-last.gif" />
		                </f:facet>
		                <f:facet name="previous">
		                    <h:graphicImage url="/images/arrow-previous.gif" />
		                </f:facet>
		                <f:facet name="next">
		                    <h:graphicImage url="/images/arrow-next.gif" />
		                </f:facet>
		                <f:facet name="fastforward">
		                    <h:graphicImage url="/images/arrow-ff.gif" />
		                </f:facet>
		                <f:facet name="fastrewind">
		                    <h:graphicImage url="/images/arrow-fr.gif" />
		                </f:facet>
		            </rich:datascroller>
		        </h:panelGrid>					        
		</h:form>					
		</div>
		<div class="clear"></div>
	</div>
	<div class="abajo-cuerpo"></div> 
	</div> <!-- Fin contenedor -->
	<div class="footer"></div>	
<script src="<%=contextRoot%>/js/jquery/lib/jquery-1.7.2.min.js"></script><!-- De ser 1ro -->
<script src="<%=contextRoot%>/js/script.js" type="text/javascript"></script><!-- De ser 2do -->
<script src="<%=contextRoot%>/js/jquery/lib/jquery.uniform.min.js"></script><!-- formularios --> 
<script src="<%=contextRoot%>/js/jquery/lib/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>
<script src="<%=contextRoot%>/js/jquery/lib/jquery.validationEngine-es.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
jQ(document).ready(function() {
	jQ("input, select, input:checkbox, input:radio, input:file").uniform();
	jQ("#userManagerForm").validationEngine('attach');
	jQ("#userManagerForm").bind("jqv.form.result", function(event, errorFound) {
        if(!errorFound) displayLoadingImage();
    });
});
</script>
<%@ include file="include/validationStatus.jsp" %>
<%@ include file="include/modalMessageWindow.jsp" %>	
    </body>
</html>
</f:view>